package MyOffer.JavaGuide;

public class PolymorphismTest2 {

    public static void main(String[] args) {
        BigFather father1 = new Son1();
        BigFather father2 = new Son2();


        PolymorphismTest2 polymorphismTest2 = new PolymorphismTest2();
        polymorphismTest2.testPolymorphism(new Son1());
        polymorphismTest2.testPolymorphism(new Son2());
    }

    //测试多态 参数具体实例对象不确定
    public void testPolymorphism(BigFather f){
        f.test();
    }

}

class BigFather{
    public void test(){
        System.out.println("Father");
    }
}

class Son1 extends  BigFather{

    @Override
    public void test(){
        System.out.println("Son1");
    }
}
class Son2 extends  BigFather{

    @Override
    public void test(){
        System.out.println("Son2");
    }
}

